<%@ page contentType="text/html; charset=UTF-8"%>

<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>


用户名:<input type="text" name="username" id="user_id">
<br/>
&nbsp;&nbsp;&nbsp;密码:<input type="password" name="password" id="password_id">
<br>
<button id="login_id">登录</button>

<script type="application/javascript">
    $("#login_id").click(function (){
        username = $("#user_id").val();
        password = $("#password_id").val();
        console.log(username + password);
        $.ajax({
            url:"/dologin",
            type:"POST",
            data:{
                username: username,
                password: password,
            },
            success: function (data) {
                if(data.code == 0) {
                    window.location.href = "/goods/100";
                } else {
                    alert("用户名/密码 错误");
                }
            },
        });
    });
</script>